package com.example.iread.http;

import com.example.iread.application.MyApplication;
import com.example.iread.bean.ResponseBean;
import com.example.iread.util.HttpUtil;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Consumer;

public class CategoryApi {

    private static final ThreadPoolExecutor threadPoolExecutor = MyApplication.getInstance().threadPoolExecutor;


    public static ResponseBean list() {
        return HttpUtil.doGet("/api/type/getTypeList");
    }

    public static void list(Consumer<ResponseBean> consumer) {
        threadPoolExecutor.execute(() -> consumer.accept(list()));
    }

    public static ResponseBean getById(int id) {
        return HttpUtil.doGet("/api/type/getTypeInfoById/" + id);
    }

    public static void getById(int id, Consumer<ResponseBean> consumer) {
        threadPoolExecutor.execute(() -> consumer.accept(getById(id)));
    }

}
